/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

//package sim;
import java.net.*;
import java.io.*;
/**
 *
 * @author Vũ Đức Tiệp
 */
public class program1 {
    public static void main(String []args)
    {
          String sentence;
          String modifiedSentence;

          //BufferedReader inFromUser = new BufferedReader( new InputStreamReader(System.in));
          try{
          Socket clientSocket = new Socket("localhost", 14188);
          DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
          BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
          //sentence = inFromUser.readLine();

          if(args.length>=2)
          {
              String temp="";
              String[] split;
              String join="";
              
              if(args[0].toLowerCase().equals("createnode")||args[0].toLowerCase().equals("deletenode"))
              {
                  temp=args[1];
                  split=temp.split("-");
                  join="("+split[0]+","+split[1]+","+args[2]+")";

                  
              }
              if(args[0].toLowerCase().equals("createobst"))
              {
                  temp=args[1];
                  split=temp.split("-");
                  join="("+split[0]+","+split[1]+")";
              }
              if(args[0].toLowerCase().equals("movefromto"))
              {
                  temp=args[1];
                  split=temp.split("-");
                  join="("+split[0]+","+split[1]+","+args[2];
                  
                  temp=args[3];
                  split=temp.split("-");
                  join+=";"+split[0]+","+split[1]+")";
              }              
              sentence = args[0]+join;
          }
          else
              sentence=args[0];


          System.out.println(sentence);

          outToServer.writeBytes(sentence + '\n');
          modifiedSentence = inFromServer.readLine();
          //System.out.println("FROM SERVER: " + modifiedSentence);

          clientSocket.close();
          } catch (Exception exc){
              System.err.println(exc);
          }
    }
}
